package pl.gpms.server.persistance.map;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import pl.gpms.client.dto.EstimateViewDTO;

@Entity
@Table(name = "V_ESTIMATE")
public class EstimateView implements Serializable {

	private static final long serialVersionUID = -876939879540198747L;
	private Double age;
	private String attrib;
	private String result;
	private String symptoms;
	private Long objectId;
	private Estimate estimate;
	
	public EstimateView() {}
	public EstimateView(Double age, String attrib, String result, String symptoms, Estimate estimate ) {
		this.age = age;
		this.attrib = attrib;
		this.result = result;
		this.symptoms = symptoms;
		this.estimate = estimate;
	}
	public EstimateView( EstimateViewDTO estimateView ) {
		this.age = estimateView.getAge();
		this.attrib = estimateView.getAttrib();
		this.result = estimateView.getResult();
		this.symptoms = estimateView.getSymptoms();
		this.estimate = new Estimate( estimateView.getEstimate() );
	}

	@Id
	@Column( name="AGE", unique = false, nullable = false, insertable=false, updatable=false )
	public Double getAge() {
		return age;
	}
	
	public void setAge( Double age ) {
		this.age = age;
	}
	
	public void setAttrib( String attrib ) {
		this.attrib = attrib;
	}
	
	@Column( name="ATTRIB", unique = false, nullable = false )
	public String getAttrib() {
		return attrib;
	}
	
	@Column( name="RESULT", unique = false, nullable = false )
	public String getResult() {
		return result;
	}
	
	public void setResult( String result ) {
		this.result = result;
	}
	
	@Column( name="SYMPTOMS", unique = false, nullable = false )
	public String getSymptoms() {
		return symptoms;
	}
	
	public void setSymptoms( String symptoms ) {
		this.symptoms = symptoms;
	}
	
	//@ManyToOne(cascade = CascadeType.ALL)
	//@JoinColumn( name="EST_ID" ) 
	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn( name="EST_ID" )
	public Estimate getEstimate() {
		return estimate;
	}
	
	public void setEstimate( Estimate estimate ) {
		this.estimate = estimate;
	}
	
	@Column( name="OBJ_ID", unique = false, nullable = false )
	public Long getObjectId() {
		return objectId;
	}
	
	public void setObjectId( Long objectId ) {
		this.objectId = objectId;
	}
}
